import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {configParams} from '../../../storage-config';

@Injectable({
  providedIn: 'root'
})
export class CommodityBrandService {

  // tablelist--URL
  public tableListUrl = '/whGoodBrand/list/page';

  // 添加商品
  public addCommodityBrandUrl = '/whGoodBrand/add';

  // 修改商品
  public updateCommodityBrandUrl = '/whGoodBrand/update';

  // 删除商品
  public deleteCommodityBrandUrl = '/whGoodBrand/remove/';

  constructor(public httpClient: HttpClient) {
  }


  post(url: any, body: any) {
    return this.httpClient.post(url, body, {headers: configParams.headers});
  }

  get(url: any, params: any) {
    return this.httpClient.get(url, {params, headers: configParams.headers});
  }

  /**
   * 查询tabledata
   * @param params 参数
   */
  public async queryTableData(params: any) {
    return await this.post(this.tableListUrl, params).toPromise();
  }

  /**
   * 添加商品品牌
   * @param params 参数
   */
  public async addCommodityBrandData(params: any) {
    return await this.post(this.addCommodityBrandUrl, params).toPromise();
  }

  /**
   * 修改商品品牌
   * @param params 参数
   */
  public async updateCommodityBrandData(params: any) {
    return await this.post(this.updateCommodityBrandUrl, params).toPromise();
  }

  /**
   * 删除商品品牌
   * @param id 商品id
   */
  public async deleteCommodityBrandData(id: any) {
    return await this.get(this.deleteCommodityBrandUrl + id, {}).toPromise();
  }
}



